package com.manage.platform.controller;

import com.manage.platform.dto.DeclareDto;
import com.manage.platform.dto.query.DeclarePageQuery;
import com.manage.platform.service.impl.DeclareServiceImpl;
import com.manage.platform.utils.R;
import com.manage.platform.utils.RPage;
import com.manage.platform.vo.DeclareVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * YWD
 * 2025/9/22
 */
@AllArgsConstructor
@RestController
@RequestMapping("/indicatorSystem")
@Tag(name = "申报管理")
public class DeclareController {

  private final DeclareServiceImpl declareServiceImpl;


    @PostMapping("/getDeclarePage")
    @Operation(summary = "查询申报列表(分页)")
    public R<RPage<List<DeclareVo>>> getDeclarePage(@RequestBody DeclarePageQuery query){
        return R.ok(declareServiceImpl.getDeclarePage(query));
    }

    @GetMapping("/getDeclareDetails/{id}")
    @Operation(summary = "查询申报详情")
    public R<DeclareVo> getDeclareDetails(@Schema(description = "申报ID") @PathVariable("id") Long id){
        return R.ok(declareServiceImpl.getDeclareDetails(id));
    }

    @PostMapping("/saveDeclare")
    @Operation(summary = "添加申报",hidden = true)
    public R<Boolean> saveDeclare(@RequestBody DeclareDto dto){
        return R.ok(declareServiceImpl.saveDeclare(dto));
    }

    @PutMapping("/updateDeclare")
    @Operation(summary = "修改申报",hidden = true)
    public R<Boolean> updateDeclare(@RequestBody DeclareDto dto){
        return R.ok(declareServiceImpl.updateDeclare(dto));
    }

    @DeleteMapping("/deleteDeclare")
    @Operation(summary = "删除申报",hidden = true)
    public R<Boolean> deleteDeclare(@Schema(description = "申报ID") @RequestParam("id") Long id){
        return R.ok(declareServiceImpl.deleteDeclare(id));
    }

    @DeleteMapping("/deleteDeclareBatch")
    @Operation(summary = "批量删除申报",hidden = true)
    public R<Boolean> deleteDeclareBatch(@Schema(description = "申报ID") @RequestBody List<Long> ids){
        return R.ok(declareServiceImpl.deleteDeclareBatch(ids));
    }

}
